home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / ImagePanelBeanInfo.java < prev    next >
Text File  |  1998-08-21  |  7KB  |  209 lines

  1. package symantec.itools.awt;
  2.  
  3. import java.beans.*;
  4. import symantec.itools.beans.*;
  5. import java.util.ResourceBundle;
  6.  
  7. //  08/25/97    LAB    Added IMAGE_NORMAL to Style popup (Addresses Mac Bug #7255).  Added
  8. //                    connections for image style constants.
  9. //  09/07/97    LAB    Fixed misspelling of descriptions.
  10. //    09/19/97    RKM    Changed name of URL property to Image URL
  11. //  08/19/98    LAB    Moved to GroupAWTAdditions folder.
  12.  
  13. /**
  14.  * BeanInfo for ImagePanel.
  15.  *
  16.  */
  17. public class ImagePanelBeanInfo extends SimpleBeanInfo {
  18.  
  19.     /**
  20.      * Constructs a ImagePanelBeanInfo object.
  21.      */
  22.     public ImagePanelBeanInfo() {
  23.     }
  24.  
  25.     /**
  26.      * Gets a BeanInfo for the superclass of this bean.
  27.      * @return BeanInfo[] containing this bean's superclass BeanInfo
  28.      */
  29.     public BeanInfo[] getAdditionalBeanInfo() {
  30.         try {
  31.             BeanInfo[] bi = new BeanInfo[1];
  32.             bi[0] = Introspector.getBeanInfo(beanClass.getSuperclass());
  33.             return bi;
  34.         }
  35.         catch (IntrospectionException e) { throw new Error(e.toString());}
  36.     }
  37.  
  38.     /**
  39.      * Gets the SymantecBeanDescriptor for this bean.
  40.      * @return an object of type SymantecBeanDescriptor
  41.      * @see symantec.itools.beans.SymantecBeanDescriptor
  42.      */
  43.     public BeanDescriptor getBeanDescriptor() {
  44.         ResourceBundle group = ResourceBundle.getBundle("symantec.itools.resources.GroupBundle");
  45.         String s=group.getString("GroupAWTAdditions"); 
  46.  
  47.         SymantecBeanDescriptor bd = new SymantecBeanDescriptor(beanClass);
  48.         bd.setFolder(s);
  49.         bd.setToolbar(s);
  50.         bd.setWinHelp("0x123B9");
  51.  
  52.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  53.         s=conn.getString("IMAGE_TILED"); 
  54.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  55.                                                 "%name%.IMAGE_TILED",s));
  56.  
  57.         s=conn.getString("IMAGE_CENTERED"); 
  58.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  59.                                                 "%name%.IMAGE_CENTERED",s));
  60.  
  61.         s=conn.getString("IMAGE_SCALED_TO_FIT"); 
  62.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  63.                                                 "%name%.IMAGE_SCALED_TO_FIT",s));
  64.  
  65.         s=conn.getString("IMAGE_NORMAL"); 
  66.         bd.addConnectionDescriptor(new ConnectionDescriptor("output", "int", "",
  67.                                                 "%name%.IMAGE_NORMAL",s));
  68.         return (BeanDescriptor) bd;
  69.     }
  70.  
  71.     /**
  72.      * Gets an image that may be used to visually represent this bean
  73.      * (in the toolbar, on a form, etc).
  74.      * @param iconKind the type of icon desired, one of: BeanInfo.ICON_MONO_16x16,
  75.      * BeanInfo.ICON_COLOR_16x16, BeanInfo.ICON_MONO_32x32, or BeanInfo.ICON_COLOR_32x32.
  76.      * @return an image for this bean, always color even if requested monochrome
  77.      * @see BeanInfo#ICON_MONO_16x16
  78.      * @see BeanInfo#ICON_COLOR_16x16
  79.      * @see BeanInfo#ICON_MONO_32x32
  80.      * @see BeanInfo#ICON_COLOR_32x32
  81.      */
  82.     public java.awt.Image getIcon(int iconKind) {
  83.         if (iconKind == BeanInfo.ICON_MONO_16x16 ||
  84.             iconKind == BeanInfo.ICON_COLOR_16x16) {
  85.             java.awt.Image img = loadImage("ImagePanelC16.gif");
  86.             return img;
  87.         }
  88.  
  89.         if (iconKind == BeanInfo.ICON_MONO_32x32 ||
  90.             iconKind == BeanInfo.ICON_COLOR_32x32) {
  91.             java.awt.Image img = loadImage("ImagePanelC32.gif");
  92.             return img;
  93.         }
  94.  
  95.         return null;
  96.     }
  97.  
  98.     /**
  99.      * Gets an array of descriptions of the methods used for "connections" by
  100.      * Visual CafΘ's Interaction Wizard.
  101.      * Included in each method description is a CONNECTIONS ConnectionDescriptor.
  102.      * @return method descriptions for this bean
  103.      * @see symantec.itools.beans.ConnectionDescriptor#CONNECTIONS
  104.      */
  105.     public MethodDescriptor[] getMethodDescriptors() {
  106.         Class[] args;
  107.         ConnectionDescriptor connection;
  108.         java.util.Vector connections;
  109.         java.util.Vector md = new java.util.Vector();
  110.         ResourceBundle conn = ResourceBundle.getBundle("symantec.itools.resources.ConnBundle");
  111.  
  112.         try{
  113.             args = new Class[1];
  114.             args[0] = java.lang.Integer.TYPE ;
  115.             MethodDescriptor setStyle = new MethodDescriptor(beanClass.getMethod("setStyle", args));
  116.  
  117.             connections = new java.util.Vector();
  118.             connection = new ConnectionDescriptor("input", "int", "",
  119.                                     "%name%.setStyle(%arg%);",
  120.                                     conn.getString("setStyle"));
  121.             connections.addElement(connection);
  122.  
  123.             setStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  124.             md.addElement(setStyle);
  125.         } catch (Exception e) { throw new Error("setStyle:: " + e.toString()); }
  126.  
  127.         try{
  128.             args = null;
  129.             MethodDescriptor getStyle = new MethodDescriptor(beanClass.getMethod("getStyle", args));
  130.  
  131.             connections = new java.util.Vector();
  132.             connection = new ConnectionDescriptor("output", "int", "",
  133.                                     "%name%.getStyle()",
  134.                                     conn.getString("getStyle"));
  135.             connections.addElement(connection);
  136.  
  137.             getStyle.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  138.             md.addElement(getStyle);
  139.         } catch (Exception e) { throw new Error("getStyle:: " + e.toString()); }
  140.  
  141.         try{
  142.             args = null;
  143.             MethodDescriptor getImageURL = new MethodDescriptor(beanClass.getMethod("getImageURL", args));
  144.  
  145.             connections = new java.util.Vector();
  146.             connection = new ConnectionDescriptor("output", "URL", "",
  147.                                     "%name%.getImageURL()",
  148.                                     conn.getString("getImageURLPanel"));
  149.             connections.addElement(connection);
  150.  
  151.             getImageURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  152.             md.addElement(getImageURL);
  153.         } catch (Exception e) { throw new Error("getImageURL:: " + e.toString()); }
  154.  
  155.         try{
  156.             args = new Class[1];
  157.             args[0] = java.net.URL.class ;
  158.             MethodDescriptor setImageURL = new MethodDescriptor(beanClass.getMethod("setImageURL", args));
  159.  
  160.             connections = new java.util.Vector();
  161.             connection = new ConnectionDescriptor("input", "URL", "",
  162.                                     "%name%.setImageURL(%arg%);",
  163.                                     conn.getString("setImageURLPanel"));
  164.             connections.addElement(connection);
  165.  
  166.             connection = new ConnectionDescriptor("input", "RelativeURL", "",
  167.                                     "%name%.setImageURL(symantec.itools.net.RelativeURL.getURL(%arg%));",
  168.                                     conn.getString("setImageURLRelative"));
  169.             connections.addElement(connection);
  170.  
  171.             setImageURL.setValue(ConnectionDescriptor.CONNECTIONS, connections);
  172.             md.addElement(setImageURL);
  173.         } catch (Exception e) { throw new Error("setImageURL:: " + e.toString()); }
  174.  
  175.         MethodDescriptor[] rv = new MethodDescriptor[md.size()];
  176.         md.copyInto(rv);
  177.  
  178.         return rv;
  179.     }
  180.  
  181.     /**
  182.      * Returns descriptions of this bean's properties.
  183.      */
  184.     public PropertyDescriptor[] getPropertyDescriptors() {
  185.         ResourceBundle prop = ResourceBundle.getBundle("symantec.itools.resources.PropBundle");
  186.  
  187.         try{
  188.         PropertyDescriptor imageURL = new PropertyDescriptor("imageURL", beanClass);
  189.         imageURL.setBound(true);
  190.         imageURL.setConstrained(true);
  191.         imageURL.setDisplayName(prop.getString("imageURL"));
  192.         imageURL.setValue("URLFILTER", prop.getString("imageURLFILTER"));
  193.  
  194.         PropertyDescriptor style = new PropertyDescriptor("style", beanClass);
  195.         style.setBound(true);
  196.         style.setConstrained(true);
  197.         style.setDisplayName(prop.getString("imageStyle"));
  198.         style.setValue("ENUMERATION", "IMAGE_TILED=0, IMAGE_CENTERED=1, IMAGE_SCALED_TO_FIT=2, IMAGE_NORMAL=3");
  199.  
  200.         PropertyDescriptor[] rv = {
  201.             imageURL,
  202.             style};
  203.         return rv;
  204.         } catch (IntrospectionException e) { throw new Error(e.toString()); }
  205.     }
  206.  
  207.     private final static Class beanClass = ImagePanel.class;
  208.  
  209.     }    //  end of class ImagePanelBeanInfo